package TJU;

import java.util.Scanner;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
 * Segment Tree problem
 * http://acm.tju.edu.cn/toj/showp3505.html
 * @author Josh Lear
 * @version 6/7/2014
 */
public class TJU_3505
{
   public static int[] tree;
   public static void main(String[] args) throws Exception{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
       int cases = Integer.parseInt(br.readLine());
       for(int z = 0; z < cases; z++){
           int n = Integer.parseInt(br.readLine());
           int[] values = new int[n];
           String[] line1 = br.readLine().split(" ");
           for(int i = 0; i < n; i++){
               values[i] = Integer.parseInt(line1[i]);
            }
           tree = new int[n*2 - 1];
           int endIndex = 2 * (n-1);
           for(int i = endIndex, k = n-1; i > endIndex - n; i--, k--){
               tree[i] = values[k];
            }
           for(int i = n-2; i > -1; i--){
               tree[i] = tree[i*2+1] + tree[i*2+2];
            }
           int queries = Integer.parseInt(br.readLine());
           for(int i = 0; i < queries; i++){
               String[] line2 = br.readLine().split(" ");
               String s = line2[0];
               int x = Integer.parseInt(line2[1]);
               int y = Integer.parseInt(line2[2]);
               if(s.equals("Inquire")){
                   bw.write(queryTree(x-1, y-1)+"");
                   bw.newLine();
                } else if(s.equals("Add")){
                    x = (endIndex)-n+(x-1);
                    updateTree(x, y);
                }
                else {
                     x = (endIndex)-n+(x-1);
                     y = Math.min(y, tree[x]); //so we dont go lower than 0.
                    updateTree(x, -y);
                }
            }
        }
        bw.flush();
    }
    public static int right(int i){ return ( i * 2 + 2); }
    public static int left(int i){ return (i * 2 + 1);}
    public static void updateTree(int i, int n){
        if(i == 1){
            tree[0] += n;
            tree[1] += n;
            return;
        }
        if(i == 0){
            tree[0] += n;
            return;
        }
        tree[i] += n;
        updateTree((i+1)/2, n);
    }
    public static int queryTree(int i, int j, int leftBound, int rightBound, int index){
        if(index > tree.length-1){
            return 0;
        }
        if(i >= leftBound && j <= rightBound){
            return tree[index];
        }
        int left = queryTree(i, (j+i)/2, leftBound, rightBound, left(index));
        int right = queryTree((i+j)/2, j, leftBound, rightBound, right(index));
        if(left == 0){
            return right;
        }
        if(right == 0){
            return left;
        }
        return left + right;
    }
    public static int queryTree(int i, int j){
        return queryTree(0, tree.length/2, i, j, 0);
    }
}
